package com.example.housebiz.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * @author ：Anitaxiaofeng
 * @description：
 * @create 2018-05-27
 **/
@Service
public class MailService {


    @Autowired
    private JavaMailSender mailSender;

    @Value("${spring.mail.username}")
    private String mailUsername;


    @Async
    public void sendMail(String titile,String url,String email) {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(mailUsername);
        message.setSubject(titile);
        message.setTo(email);
        message.setText(url);
        mailSender.send(message);
    }


}
